package com.atguigu.springcloud.config;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;


@Configuration
public class ApplicationContextConfig {

    @Bean
//    @LoadBalanced          //开启负载均衡功能， 否则会找不到主机异常
    /**
     * There was an unexpected error (type=Internal Server Error, status=500).
     * I/O error on GET request for "http://CLOUD-PAYMENT-SERVICE/payment/get/1": CLOUD-PAYMENT-SERVICE;
     * nested exception is java.net.UnknownHostException: CLOUD-PAYMENT-SERVICE
     * org.springframework.web.client.ResourceAccessException:
     * I/O error on GET request for "http://CLOUD-PAYMENT-SERVICE/payment/get/1":
     * CLOUD-PAYMENT-SERVICE; nested exception is java.net.UnknownHostException: CLOUD-PAYMENT-SERVICE
     */
    public RestTemplate getRestTemplate(){
        return  new RestTemplate();
    }
}
//applicationCOntext.xml    <bean id="" class ="">             相当于